package com.welcome_2.beta;

import android.app.Service;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.IBinder;
import android.util.Log;
/**
public class UpdaterService extends Service{
	private static final String TAG = UpdaterService.class.getSimpleName();
	private Updater updater;

	  @Override
	  public IBinder onBind(Intent intent) {
	    return null;
	  }

	  @Override
	  public void onCreate() {
	    super.onCreate();

	    updater = new Updater();

	    Log.d(TAG, "onCreated");
	  }

	  @Override
	  public synchronized void onStart(Intent intent, int startId) {
	    super.onStart(intent, startId);

	    // Start the updater
	    if (!updater.isRunning()) {
	      updater.start();
	    }

	    Log.d(TAG, "onStart'd");
	  }

	  @Override
	  public synchronized void onDestroy() {
	    super.onDestroy();

	    // Stop the updater
	    if (updater.isRunning()) {
	      updater.interrupt();
	    }

	    updater = null;

	    Log.d(TAG, "onDestroy'd");
	  }

	  // ///// Updater Thread
	  class Updater extends Thread {
	    private static final long DELAY = 60000; // one minute
	    private boolean isRunning = false;

	    public Updater() {
	      super("Updater");
	    }

	    @Override
	    public void run() {
	      isRunning = true;
	      while (isRunning) {
	        try {
	          // Do something
	          Log.d(TAG, "Updater run'ing");

	          // Open Database
	          DbHelper dbHelper = new DbHelper(UpdaterService.this);
	          SQLiteDatabase db = dbHelper.getWritableDatabase();

	          // Get friends statuses

	            // Insert into database
	            db.insertWithOnConflict(DbHelper.TABLE, null, values,
	            SQLiteDatabase.CONFLICT_REPLACE);

	            // INSERT INTO statuses (_id, yamba_createdAt, yamba_text )
	            // VALUES (2356787654345, 1234567890, 'Hello from San Jose!')

	            Log.d(TAG, String.format("%s: %s", status.user.name, status.text));
	          }

	          // Close Database
	          db.close();
	          dbHelper.close();

	          // Sleep
	          Thread.sleep(DELAY);
	        } catch (InterruptedException e) {
	          // Interrupted
	          isRunning = false;
	        }
	        
	      } // while
	    }

	    public boolean isRunning() {
	      return this.isRunning;
	    }

	  }
  }
**/
	
